package com.ititer.dao.impl;

import static com.ititer.util.MyBatisCriteriaFactory.newCriteria;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ititer.dao.AccountDomainsDao;
import com.ititer.mapper.AccountDomainsMapper;
import com.ititer.model.AccountDomains;
import com.ititer.model.AccountDomainsCriteria;

@Repository
public class AccountDomainsDaoImpl implements AccountDomainsDao {
	@Autowired
	private AccountDomainsMapper domainMapper;

	@Override
	public int deleteByAccount(Integer id) {
		AccountDomainsCriteria deleteExample = newCriteria(AccountDomainsCriteria.class);
		deleteExample.createCriteria().andAccountIdEqualTo(id);
		return domainMapper.deleteByExample(deleteExample);
	}

	@Override
	public int create(AccountDomains ad) {
		return domainMapper.insert(ad);
	}

	@Override
	public List<AccountDomains> getDomains(Integer accountid) {
		AccountDomainsCriteria example = newCriteria(AccountDomainsCriteria.class);
		example.createCriteria().andAccountIdEqualTo(accountid);
		return domainMapper.selectByExample(example);
	}

}
